package com.zw.thy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by zwz
 * date 2016/11/23
 * project com.zw.thy.controller
 */
@Controller
public class Hello {

    @RequestMapping("/hello")
    public String hello(Model model) {
        model.addAttribute("hello","from TemplateController.helloFtl");
        return "hello";
    }

    @RequestMapping("/hello1")
    public String hello1(Model model) {
        model.addAttribute("hello","from TemplateController.helloFtl");
        UserBean userBean = new UserBean();
        userBean.setAge(31);
        userBean.setName("jack");
        userBean.setEmil("123@123.com");
        userBean.setNikName("J");
        model.addAttribute("user",userBean);
        return "hello1";
    }
    @RequestMapping("/hello2")
    public String hello2(Model model) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
        Calendar cal = Calendar.getInstance();
        model.addAttribute("today", dateFormat.format(cal.getTime()));
        model.addAttribute("today2", new Date());
        model.addAttribute("stringArray", new String[]{"a","b","c"});
        List list = new ArrayList();
        list.add(3);
        list.add(8);
        list.add(5);
        list.add(10);
        list.add(4);

        model.addAttribute("list", list);
        model.addAttribute("age", 20);
        model.addAttribute("isMarry", true);


        UserBean userBean = new UserBean();
//        userBean.setAge(31);
        userBean.setName("jack");
        userBean.setEmil("123@123.com");
        userBean.setNikName("J");
        model.addAttribute("user",userBean);
        return "hello2";
    }


}
